package com.example.exerciseextract.Movdel;

import com.example.exerciseextract.base.BaseModel;
import com.example.exerciseextract.bean.RvBean;
import com.example.exerciseextract.net.ApiService;
import com.example.exerciseextract.net.HttpUtil;
import com.example.exerciseextract.net.ResultCallBack;

import java.util.ArrayList;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import io.reactivex.subscribers.ResourceSubscriber;

/**
 * Created by 阿炜啊 on 2020/7/12.
 */

public class MainPageModel extends BaseModel {
    public void getData(final ResultCallBack<RvBean> callBack){
        addDisposable(
                HttpUtil.getInstance()
                        .getWanService()
                        .getDate()
                        .subscribeOn(Schedulers.io())
                        .observeOn(AndroidSchedulers.mainThread())
                        .subscribeWith(new ResourceSubscriber<RvBean>() {

                            @Override
                            public void onNext(RvBean naviBean) {

                                callBack.onSuccess((ArrayList)naviBean.getData().getDatas());

                            }

                            @Override
                            public void onError(Throwable t) {
                                callBack.onFail(t.toString());
                            }

                            @Override
                            public void onComplete() {

                            }
                        })

        );







    }
}
